
if not minetest.global_exists("banned_names") then banned_names = {} end
banned_names.modpath = minetest.get_modpath("banned_names")



-- Public API function.
-- Returns true if name is all numeric, otherwise returns false.
banned_names.all_numeric = function(pname)
  if string.find(pname, "^%d+$") then
    return true
  end
  return false
end

banned_names.guest_name = function(pname)
	-- Mobile users make up most traffic. We probably shouldn't do this.
	---[[
  -- Names typically generated by tablet clients when the user hasn't
  -- actually entered anything in the name field.
  if string.find(pname, "^[A-Z][a-z]+%d%d%d$") or
     -- Anything with `guest` in it.
     string.find(pname, "[Gg][Uu][Ee][Ss][Tt]") then
    return true
  end
	--]]
  return false
end

-- Returns `true` if the name is reserved for server usage.
-- (Such as special names used in code.)
banned_names.reserved_name = function(pname)
  local lower = string.lower(pname)
	-- Used for server emails, server ownership, etc.
	-- Also for public beds.
  if lower == "server" then
    return true
  end
	-- Used as the dummy value for string metadata.
	if lower == "dummy" then
		return true
	end
	-- No devil numbers.
	if string.find(pname, "666+") then
		return true
	end
  return false
end



-- One-time only code.
if not banned_names.run_once then
  local c = "banned_names:core"
  local f = banned_names.modpath .. "/init.lua"
  reload.register_file(c, f, false)
  
  banned_names.run_once = true
end
